import com.demo.HelloMain;
import com.demo.domain.UserEntity;
import com.demo.service.virtual.HelloDaoInterface;
import com.demo.util.GENDER;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = HelloMain.class)
public class JpaHelloTester {
    @Autowired
    private HelloDaoInterface helloDaoInterface;

    @Test
    public void test() throws Exception {
        /**
         * Initial Data
         */
        helloDaoInterface.save(new UserEntity("Tim Duncan", 40, GENDER.MALE));
        helloDaoInterface.save(new UserEntity("Manu Ginobili", 40, GENDER.MALE));
        helloDaoInterface.save(new UserEntity("Tony Park", 38, GENDER.MALE));

        /**
         * Test Interface
         */
        System.out.println(helloDaoInterface.getUserEntityByAge(38));
        System.out.println(helloDaoInterface.getUserEntityByName("Tony Park"));
    }
}
